/*
题目链接：https://leetcode.cn/problems/count-numbers-with-unique-digits/description/
357. 统计各位数字都不同的数字个数-中等
完成日期：2024/10/3
数位DP
*/

class Solution {
public:
    int countNumbersWithUniqueDigits(int n) {
        if (n == 0) {
            return 1;
        }
        if (n == 1) {
            return 10;
        }
        int ans = 10, cur = 9;
        for (int i = 0; i < n - 1; ++i) {
            cur *= 9 - i;
            ans += cur;
        }
        return ans;
    }
};